package tt.dz.mvc.controller.base;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import tt.dz.entity.base.JsonCommon;
import tt.dz.service.sys.OtherPartnerService;
import tt.dz.util.OmsConstant.MsgCodeEnum;

@Controller
@RequestMapping("/sysApi")
public class SystemAction extends BaseAction
{
	@Autowired
	private OtherPartnerService otherPartnerServiceImpl;
	@RequestMapping("logout")
	@ResponseBody
	public JsonCommon<String> logout(HttpServletRequest request, HttpServletResponse response)
	{
		request.getSession().invalidate();
		JsonCommon<String> jc = new JsonCommon<>();
		jc.setMsg(MsgCodeEnum.SUCCESS.getMsgInfo());
		jc.setCode(MsgCodeEnum.SUCCESS.getMsgCode());
		jc.setPojo("logout success!!");
		return jc;
	}
	
	@RequestMapping(value="partnerLogin",method=RequestMethod.POST)
	@ResponseBody
	public JsonCommon<?> partnerLogin(HttpServletRequest request, HttpServletResponse response)
	{
		//第三方用户登录
		String channelNo = request.getHeader("channelNo");
		String account = request.getParameter("account");
		String password = request.getParameter("password");
		return this.otherPartnerServiceImpl.partnerLogin(account, password, channelNo);
	}
}
